
package org.interview.reflection.hashcode;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class PojoCorrectHCTest
{

	private static final long count = 10000;

	public static void main(String[] args)
	{

		List<PojoCorrectHC> list = PojoGenerator.generatePojoCorrectHCList(count);
		
		Map<PojoCorrectHC, String> map = new HashMap<PojoCorrectHC, String>();
		
		for (PojoCorrectHC pojoCorrectHC : list) {
			map.put(pojoCorrectHC, pojoCorrectHC.getName());
		}
		
		System.out.println("collection size : " + map.size());
		
		long start = System.currentTimeMillis();
		for (PojoCorrectHC pojoCorrectHC : list) {
			PojoCorrectHC pojoCorrectHCForSearch = new PojoCorrectHC();
			pojoCorrectHCForSearch.setId(pojoCorrectHC.getId());
			
			String value = map.get(pojoCorrectHCForSearch);
			if (value == null || !value.equals(pojoCorrectHC.getName()))
			{
				System.out.println("error: pojo found wrong");
			}
		}
		long finish = System.currentTimeMillis();
		long result = finish - start;
		System.out.println("Result = " + result + " ms");

	}

}
